
package com.zsrt.day20170425.ch02;



import static org.junit.Assert.*;

import java.io.File;
import java.io.FileReader;
import java.util.List;
import java.util.Properties;
import java.util.Scanner;

import org.dom4j.Document;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;
import org.junit.Test;



public class Test1 {

	@Test
	public void test01() throws Exception {
		// 创建saxreader对象  
        SAXReader reader = new SAXReader();  
        // 读取一个文件，把这个文件转换成Document对象  
        Document document = reader.read(new File("src/com/zsrt/xml/student.xml"));

		List<Element> nodes = document.selectNodes("//student");
		for(Element e:nodes){
			System.out.println(e.elementText("name"));
		}
	}
	
	/**
	 * 配置文件的使用
	 * @throws Exception
	 */
	@Test
	public void loginTest() throws Exception {
		
		Properties pro = new Properties();
		pro.load(new FileReader("config/jdbc.properties"));
		String un = pro.getProperty("username");
		String pw = pro.getProperty("password");
		Scanner scanner = new Scanner(System.in);
		System.out.println("请输入用户名");
		String un1 = scanner.next();
		System.out.println("请输入密码");
		String pw1 = scanner.next();
		if(un.equals(un1) && pw.equals(pw1)){
			System.out.println("登陆成功");
		}else{
			
			System.out.println("登陆失败");
		}
		scanner.close();
	}
}
